package com.gelsanalyzer.application;

import javax.swing.*;

import com.gelsanalyzer.core.*;
import com.gelsanalyzer.ui.swing.*;

public class RunStudentApplication {

    /**
     * @param args
     */
    public static void main(String[] args) {
        
        try {
            UIManager
                .setLookAndFeel(
                    "com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
        } catch ( ClassNotFoundException x ) {
            x.printStackTrace();
        } catch ( InstantiationException x ) {
            x.printStackTrace();
        } catch ( IllegalAccessException x ) {
            x.printStackTrace();
        } catch ( UnsupportedLookAndFeelException x ) {
            x.printStackTrace();
        }

        StudentAppFrameController safc = new StudentAppFrameController();
        ActionFactory.setMasterController(safc);

        // Models
        StudentAppFrameModel safm = new StudentAppFrameModel();
        CourseSelectorModel csm = new CourseSelectorModel();
        CourseEntryModel cem = new CourseEntryModel();
        CourseOptimizerModel com = new CourseOptimizerModel();
        ReportViewerModel rvm = new ReportViewerModel();
        // Views
        StudentAppFrameView safv = new StudentAppFrameView();
        CourseSelectorView csv = new CourseSelectorView();
        CourseEntryView cev = new CourseEntryView();
        CourseOptimizerView cov = new CourseOptimizerView();
        ReportViewerView rvv = new ReportViewerView();
        
        // View specific init methods
        safv.setJMenuBar(new CourseMgmtMenuBar());
        safv.addComponents(cev, null, rvv, csv, cov);
        
        // Controllers
        CourseSelectorController csc = new CourseSelectorController(csv, csm);
        CourseEntryController cec = new CourseEntryController(cev, cem);
        CourseOptimizerController coc = new CourseOptimizerController(cov, com);
        ReportViewerController rvc = new ReportViewerController(rvv, rvm);

        // Controller specific init methods
        safc.setModel(safm);
        safc.setView(safv);

        safc.addChild(csc);
        safc.addChild(cec);
        safc.addChild(coc);
        safc.addChild(rvc);

        safv.pack();
        safv.setVisible(true);

    }
}
